/**
 *
 * @param mode
 * @param readOnlyCells
 * @param cellTypeList
 */
export const hlCells = (mode: string, readOnlyCells: string[], cellTypeList: App.CellTypeItem[]) => {
    return {
        cells: (row: number, col: number) => {
            let config = {
                readOnly: mode === 'preview',
                type: 'text'
            };
            if (readOnlyCells.includes(row + '-' + col)) {
                config.readOnly = true;
            }
            cellTypeList.map(item => {
                if (item.row === row && item.col === col) {
                    config.type = item.type;
                }
                if (item.type === 'autocomplete') {
                    const autocompleteMap = {
                        source: item.source,
                        strict: item.strict
                    };
                    config = {
                        ...config,
                        ...autocompleteMap
                    }
                }
                if (item.type === 'date') {
                    const dateMap = {
                        dateFormat: item.dateFormat
                    };
                    config = {
                        ...config,
                        ...dateMap
                    }
                }
                if (item.type === 'checkbox') {
                    const checkBoxMap = {
                        label: {
                            position: item.label?.position,
                            value: item.label?.value
                        }
                    }
                    config = {
                        ...config,
                        ...checkBoxMap
                    }
                }
                if (item.type === 'dropdown') {
                    const dropdownMap = {
                        source: item.source
                    };
                    config = {
                        ...config,
                        ...dropdownMap
                    }
                }
            });
            return config;
        }
    }
}
